// Define pin numbers const int buttonPin = 11; // the number of the pushbutton pin const int ledPin = 10; // the number of the LED pin // Variables will change: int buttonState = 0; // variable for reading the pushbutton status void setup() { // Initialize the LED pin as an output: pinMode(ledPin, OUTPUT); // Initialize the pushbutton pin as an input with internal pull-up resistor: pinMode(buttonPin, INPUT_PULLUP); } void loop() { // Read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // Check if the pushbutton is pressed. // If it is, the buttonState is LOW: if (buttonState == LOW) { // Turn LED on: digitalWrite(ledPin, HIGH); } else { // Turn LED off: digitalWrite(ledPin, LOW); } }